package io.dy;

import io.dy.utils.JedisConnectionFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import redis.clients.jedis.Jedis;

/**
 * @author : dmj
 * @date: 2024/6/4 4:48 下午
 * @description: jedis 连接池测试
 */
public class JedisConnectFactory {

    private Jedis jedis;


    @Test
    void testString(){
        String result = jedis.set("age", "19");
        System.out.println(result);

        String name = jedis.get("age");
        System.out.println(name);

        jedis.eval("", 1, "ss");
    }



    @BeforeEach
    void setUp(){

        //1、建立连接
        jedis = JedisConnectionFactory.get();

        //2、设置密码
        //jedis.auth("");

        //3、选择库
        jedis.select(0);
    }

    @AfterEach
    void close(){
        if(jedis != null){
            jedis.close();
        }
    }
}
